package org.yys.demo;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.yys.constant.MqConstant;

public class OnewayDemo {

    public void onewayProducer() throws MQClientException, RemotingException, InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer("oneway-producer-group");
        producer.setNamesrvAddr(MqConstant.NAMESRV_ADDR);
        producer.start();

        Message message = new Message("onewayTopic", "日志消息".getBytes());
        producer.sendOneway(message);

        System.out.println("成功");
        producer.shutdown();


    }
}
